<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<style type="text/css">
.widthDu {
	width: 200px;
}
</style>
<form:form commandName="model" cssClass="validate" id="changeForm"
	action="change/change/save">
	<input name="id" type="hidden" value="${model.id }">

	<div class="header">
		<h3>变更信息</h3>
	</div>
	<table class="form-table">
		<tr>

			<td class="td1">变更类型：</td>
			<td class="td2"><isperp:dictSelector id="changeType"
					typeCode="CI_CHANGETYPE" name="changeType" hasEmptyValue="false"
					dictCssClass="required" selectedValue="${model.changeType }"></isperp:dictSelector>


			</td>
			<td class="td1">分类：</td>
			<td class="td2"><form:hidden path="chgCategoryId" /> <isperp:treeSelector
					url="change/category/getTree" id="chgCategorySelector"
					name="chgCategoryName" displayValue="${model.chgCategoryName }"
					valueControlId="chgCategoryId" displayValueCssClass="required"></isperp:treeSelector>
			</td>
		</tr>
		<tr>
			<td class="td1">请求人：</td>
			<td class="td2"><form:hidden path="requester" /> <isperp:departmentUser
					displayValue="${model.requesterName }" valueControlId="requester"
					id="requesterName" name="requesterName"
					displayValueCssClass="required"></isperp:departmentUser>
			</td>

			<td class="td1">紧急度：</td>

			<td class="td2"><isperp:dictSelector id="urgencyName"
					typeCode="INCIDENT_URGENCY" name="urgencyName"
					hasEmptyValue="false" selectedValue="${model.urgencyName }"
					onchangeFunc="resetPriorityName()">
				</isperp:dictSelector></td>



		</tr>

		<tr>

			<td class="td1">请求日期：</td>
			<td class="td2"><input id="requestDate" name="requestDate"
				value="${model.requestDate }" class="required" type="datetime">
			</td>
			<td class="td1">影响度：</td>

			<td class="td2"><isperp:dictSelector id="effectName"
					typeCode="INCIDENT_EFFECT" name="effectName" hasEmptyValue="false"
					selectedValue="${model.effectName }"
					onchangeFunc="resetPriorityName()">
				</isperp:dictSelector>
			</td>


		</tr>
		<tr>
			<td class="td1">风险等级：</td>
			<td class="td2"><form:select path="riskRank" cssClass="required"
					items="${riskRanks }" itemValue="name" itemLabel="name" /></td>
			<td class="td1">优先级：</td>

			<td class="td2"><isperp:dictSelector id="priorityName"
					typeCode="INCIDENT_PRIORITY" name="priorityName"
					hasEmptyValue="false" selectedValue="${model.priorityName }">
				</isperp:dictSelector>
			</td>


		</tr>
		<tr>
			<td class="td1">选择项目：</td>
			<td class="td2" colspan="3"><form:select path="projectId"
					cssClass="required search" items="${projects }" itemValue="id"
					itemLabel="name" data-width="310px" />
			</td>
		<tr>
		<tr>
			<td class="td1">变更标题：</td>
			<td class="td2" colspan="3"><input id="changeTitle" name="title"
				value="${model.title }" class="required" type="text" maxlength="200"
				style="width:80%">
			</td>
		</tr>
		<tr>
			<td class="td1">变更描述：</td>
			<td class="td2" colspan="3"><textarea id="changeDescription"
					class="required" name="description">${model.description }</textarea>
			</td>
		</tr>


		<tr>
			<td class="td1">附件：</td>
			<td class="td2" colspan="3"><isperp:uploader
					sourceId="${model.id }" id="changeFiles"></isperp:uploader>
			</td>
		</tr>
		<%-- 		<tr id="assetTr">
			<td class="td1" colspan="3">关联资产：</td>
			<td class="td2"><isperp:ciUseRelation relationId="${model.id }"
					viewOnly="false" relationType="changeProcess"></isperp:ciUseRelation>
			</td>
		</tr> --%>
		<tr id="assetTr">
			<td class="td1">关联资产：</td>
			<td class="td2" colspan="3"><isperp:ciUseRelation
					relationId="${model.id }" relationType="changeProcess"></isperp:ciUseRelation>
			</td>
		</tr>
		<tr>
			<td class="td1">计划开始时间：</td>
			<td class="td2"><input id="planStartTime" name="planStartTime"
				value="${model.planStartTime }" class="required" type="datetime">
			</td>
			<td class="td1">计划结束时间：</td>
			<td class="td2"><input id="planEndTime" name="planEndTime"
				value="${model.planEndTime }" class="required" type="datetime">
			</td>
		</tr>
	</table>

	<div class="header">
		<h3>支持人员</h3>
	</div>
	<table class="form-table">
		<tr>
			<td class="td1">评估人：</td>
			<td class="td2"><form:hidden path="supporter" /> <isperp:departmentUser
					displayValue="${model.supporterName }" valueControlId="supporter" idFieldName="name"
					id="supporterName" name="supporterName"
				 
					displayValueCssClass="required"></isperp:departmentUser></td>
		</tr>
		<%-- <tr>
			<td class="td1">变更委员会：</td>
			<td class="td2"><form:hidden path="approver" /> <isperp:departmentUser
					idFieldName="name" displayValue="${model.approverName }" 
					valueControlId="approver" multiselect="true" id="approverName"
					name="approverName" displayValueCssClass="widthDu required"></isperp:departmentUser>
			</td>
		</tr> --%>
	</table>

	<div class="header">
		<h3>关联流程</h3>
	</div>
	<isperp:processRelation businessKey="${model.id }" readonly="true"
		processKey="changeProcess" projectIdControl="projectId"></isperp:processRelation>

</form:form>

<script type="text/javascript">
	function resetPriorityName() {
		var $urgencyName = $("#urgencyName option:selected"), urgencyNameCode = parseInt($urgencyName.data("code"));
		var $effectName = $("#effectName option:selected"), effectNameCode = parseInt($effectName.data("code"));

		var ueVal = urgencyNameCode + effectNameCode;

		var $priorityName = $("#priorityName"), $priorityNameOptions = $("#priorityName option");

		for ( var i = 0; i < $priorityNameOptions.length; i++) {
			var $item = $($priorityNameOptions[i]), code = parseInt($item.data("code"));

			if (ueVal >= code) {
				$priorityName.val($item.val());
				$("#priorityName").trigger("chosen:updated");
				return;
			}
		}

	}
</script>


<isperp:buttonList>
	<isperp:processButtons processKey="changeProcess" formId="changeForm"
		processId="${model.processId }" businessKey="${model.id }"></isperp:processButtons>
</isperp:buttonList>



